package com.project.isaacwiki.mapper;

import com.project.isaacwiki.pojo.ImgPath;
import com.project.isaacwiki.pojo.Users;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface MapperLogin {

    @Select("select * from users where username=#{username} and password=#{password}")
    Users login(String username, String password);

    @Select("select * from img_path where user_id = #{id}")
    ImgPath queryImage(Integer id);

    @Insert("insert into users(username, password, name, state) values(#{username}, #{password}, #{name}, #{state})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    Integer register(Users user);

    @Insert("insert into img_path(user_id, path) values(#{id}, #{path})")
    Integer registerImgPath(Integer id, String path);

    @Select("select * from users where username=#{username}")
    Users queryUser(String username);
}
